package com.tron.inheritance;

public class Manager extends Employee {
    /**
     * 从父类中继承的域
     *     private String id;
     *     private String name;
     *     private String type;
     *     private Double salary;
     */
    private Double bonus;

    public Manager(String id,String name,String type,Double salary,Double bonus) {
        /**
         * 如果子类没有显示的调用父类构造器，将会默认调用父类的无参构造器，反之则不会。polymorphism
         */
        super(id,name,type,salary);
        this.bonus = bonus;
    }

    @Override
    public Double getSalary() {
        /**
         * super 不是引用，他只是一个指示编译调用父类方法的一个关键字
         * 虽然子类也有salary域，但是只能通过父类的公开方法来访问
         */
        return super.getSalary() + bonus;
    }

    public Double getBonus() {
        return bonus;
    }

    public void setBonus(Double bonus) {
        this.bonus = bonus;
    }
}
